package com.cnebula.dataprocess.task.demo;

import java.io.InputStreamReader;
import java.io.Reader;

import org.apache.rocketmq.spring.starter.core.RocketMQTemplate;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ApplicationContext;

import com.cnebula.dataprocess.task.center.message.MainTaskMessage;
import com.google.gson.Gson;

@SpringBootApplication
public class App {

	public static void main(String[] args){
		
		ApplicationContext ctx = new SpringApplicationBuilder().sources(App.class).run(args);
		
		RocketMQTemplate rocketMQTemplate = ctx.getBean(RocketMQTemplate.class);
		
		
		Gson gson = new Gson();
		
		Reader json = new InputStreamReader(ctx.getClass().getResourceAsStream("/PreOrderBook.json"));
		MainTaskMessage obj = gson.fromJson(json, MainTaskMessage.class);
		System.out.println(gson.toJson(obj));
		
		rocketMQTemplate.convertAndSend("mysql_task_new", obj);
		
		
		
	}
}
